package bintree.heap;


import seqlist.queue.Queue;

/**
        * 基于最大堆的优先级队列
        * @author yuisama
        * @date 2022/05/17 20:54
        **/
public class PriorityQueue  implements Queue<Integer> {
    private MaxHeap heap;
    public PriorityQueue(){
        heap = new MaxHeap();
    }
    @Override
    public void offer(Integer val) {
        heap.add(val);
    }

    @Override
    public Integer poll() {
        return heap.extractMax();
    }

    @Override
    public Integer peek() {
        return heap.peekMax();
    }

    @Override
    public boolean isEmpty() {
        return heap.isEmpty();
    }
}
